<template>
	<view class="content">
		<view class="menu-item" v-if="type == 1">
			<view class="tab-item" :class="tabActive==2117?'active':''" @click="bindActive(2117)">通知公告</view>
			<view class="tab-item" :class="tabActive==2118?'active':''" @click="bindActive(2118)">引才政策</view>
			<view class="tab-item" :class="tabActive==2119?'active':''" @click="bindActive(2119)">工作动态</view>
			<view class="tab-item" :class="tabActive==2120?'active':''" @click="bindActive(2120)">急需岗位</view>
		</view>
		<view class="info-block">
			<view class="article-list">
				<template v-if="newsList.length>0">
					<view @click="navigate('/page_other/article/detail?id='+item.id)" class="article-item"
						v-for="(item,index) in newsList" :key="item.id">
						<image mode="aspectFill" :src="item.ima_url" class="cover-photo"></image>
						<view class="info">
							<view class="title overflow-line">{{item.title}}</view>
							<view class="abstract">{{item.abstract}}</view>
							<view class="time">{{item.crt_time}}</view>
						</view>
					</view>
				</template>
				<view style="text-align: center;" v-else>暂无数据</view>
			</view>
			<!-- <template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id">
					<image :src="item" class="img"></image>
					<view class="left-item">
						<view class="title"> 姓名：{{item.name}}</view>
						<view class="title"> 职务：{{item.unit}}</view>
						<view class="title"> 联系电话：{{item.phone}}</view>
					</view>
				</view>
			</template>
			<template>
				<view style="text-align: center;">暂无数据</view>
			</template> -->
		</view>
	</view>
</template>

<script>
	import {
		getNewsList as getNewsListApi
	} from '@/api/notice.js'
	export default {
		data() {
			return {
				tabActive: 2117,
				imageUrl: '',
				newsList: [],
				list: [{
						id: 1,
						img: '',
						name: '王建国',
						unit: '主任',
						phone: '18298722023'
					},
					{
						id: 2,
						img: '',
						name: '王建国',
						unit: '主任',
						phone: '18298722023'
					}
				],
				type: null
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			bindActive(index) {
				this.tabActive = index
				this.getNewsList()
			},
			getNewsList() {
				getNewsListApi({
					page: 1,
					limit: 3,
					type: this.tabActive
				}).then((res) => {
					this.newsList = res.list ?? [];
				})
			},
		},
		onLoad(e) {
			
			this.imageUrl = this.globalConfig.imageUrl
			uni.setNavigationBarTitle({
				title: e.name
			})
			this.type = e.type
			this.getNewsList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;

		.menu-item {
			width: 100%;
			height: 100rpx;
			display: flex;
			flex-direction: row;
			justify-content: space-around;

			.tab-item {
				margin-top: 30rpx;
				height: 60rpx;
				font-size: 30rpx;
			}

			.tab-item.active {
				color: #FE7526;
				font-size: 34rpx;
				font-weight: bold;
				height: 60rpx;
				border-bottom: 6rpx solid #FE7526;
			}
		}

		.info-block {
			padding: 30rpx;
			width: 100%;

			.article-list {
				width: 100%;
				display: flex;
				flex-direction: column;

				.article-item {
					height: 220rpx;
					width: 100%;
					padding: 30rpx;
					background: #fff;
					display: flex;
					flex-direction: row;
					margin-bottom: 30rpx;
					box-shadow: 0 0 10px 0 #efefef;
					border-radius: 10rpx;

					.cover-photo {
						width: 160rpx;
						height: 160rpx;
						border-radius: 10rpx;
						margin-right: 20rpx;
						background: #efefef;
					}

					.info {
						width: calc(100% - 180rpx);
						height: 100%;

						.title {
							font-weight: bold;
						}

						.abstract {
							font-size: 24rpx;
							color: #999;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							margin-top: 6rpx;
							line-height: 1.5;
						}

						.time {
							font-size: 28rpx;
							color: #999;
						}
					}
				}

				.article-item:last-child {
					border: none;
				}
			}

			.info-item {
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-bottom: 30rpx;
				padding: 30rpx;
				background: #fff;
				box-shadow: 0 0 10px 0 #efefef;

				.img {
					width: 180rpx;
					height: 240rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
					background-color: #efefef;
				}

				.left-item {
					display: flex;
					flex-direction: column;
					height: 100%;
					justify-content: space-between;

					.title {
						margin-bottom: 20rpx;
					}
				}
			}
		}

	}
</style>